package com.wj.onlinemusic.mapper;
import com.wj.onlinemusic.model.Music;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MusicMapper {
    @Insert("insert into music(title,singer,time,url,userid) values" +
            "(#{title},#{singer},#{time},#{url},#{userid})")
    Integer insert(String title, String singer,String time, String url,Integer userid);

    @Select("select * from music where id = #{id}")
    Music findMusicById(int id);
    
    @Delete("delete from music where id = #{musicId}")
    Integer deleteMusicById(int musicId);

    @Select("select * from music where title like concat('%',#{musicName},'%')")
    List<Music> findMusicByName(String musicName);

    @Select("select * from music")
    List<Music> findMusic();
}